#ifndef GAMESTATE_H_
#define GAMESTATE_H_

#include "EventHandler.h"
#include <string>

/* Abstract base class to uniform the gamestate management technique 
 * The Game singleton abstracts all of its updating and drawing to a gamestate 
 * which internally manage what is active and what is not 
 */
class GameState : public EventHandler
{
public:
    GameState()
    {
        m_initialised = false;
    }
    virtual ~GameState()		= 0{}
	virtual void Update()		= 0;
	virtual void Draw()			= 0;
	virtual void Initialise()	= 0;
	virtual void CleanUp()		= 0{}
	virtual void ChangeState(GameState*);
	virtual void OnResume()		= 0{}
    const bool IsInitialised() const
    {
        return m_initialised;
    }
    void SetVsync(int interval = 1);
    void CheckErrors();
    void RenderText(float x, float y, const std::string& s, float r, float g, float b);
    float Random(float min, float max);

protected:
	bool m_initialised;
};

#define TRACE_BEGIN {unsigned char* a = new unsigned char; a = new unsigned char[2]; a = new unsigned char[3];}
#define TRACE_END {unsigned char* a = new unsigned char[4]; a = new unsigned char[5]; a = new unsigned char[6];}
static int count = 0;
#define TRACE_ONCE_BEGIN {{if(count == 0){TRACE_BEGIN count++;}}}
#define TRACE_ONCE_END {{if(count == 1){TRACE_END count++;}}}

#endif